package nowember.test_11_14;

import java.util.Scanner;

public class TestMain1 {
    public static int count = 0;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int len = scanner.nextInt();
            int[] arr = new int[len];
            int[] tmp = new int[len];
            for (int j = 0; j < len; j++) {
                arr[j] = j;
                tmp[j] = j;
            }
            count=0;
            getResult(arr,tmp);
            System.out.println(count);
        }
    }
    private static void getResult(int[] arr,int[] tmp) {
        while (true) {

            boolean flag = true;
            count++;
            for (int i = 0; i < arr.length; i++) {
                if (i % 2 == 0) {
                    arr[i] = tmp[i / 2];
                } else {
                    arr[i] = tmp[arr.length / 2 + (i - 1) / 2];
                }
                if (arr[i] != i) {
                    flag = false;
                }
            }
            for(int i = 0; i < arr.length; i++) {
                tmp[i] = arr[i];
            }

            if (flag) {
                break;
            }
    }

    }
}
